//2009/08/08 00:07:13
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

class Inchworm
{
public:
    int lunchtime(int branch, int rest, int leaf)
    {
        return 1 + branch/lcm(rest, leaf);
    }
private:
    int gcd(int a, int b)
    {
        return b == 0 ? a : gcd(b, a%b);
    }
	int lcm(int a, int b)
	{
		return a / gcd(a,b) * b;
	}
};
